<template>
  <div>
    <card>
      <el-form slot="content">
        <el-form-item label="年度" prop="evaluateDate">
          <el-date-picker v-model="searchForm.evaluateDate" type="year" placeholder="选择年份" :editable="false" :clearable="false"></el-date-picker>
        </el-form-item>
      </el-form>
    </card>
    <card style="margin-top: 20px">
      <el-table slot="content" v-loading="loading" :data="list" stripe border="true">
        <el-table-column type="index" label="编号" width="100" align="center"></el-table-column>
        <el-table-column type="name" label="年度" width="130" align="center"></el-table-column>
        <el-table-column type="name" label="节假日名称" align="center"></el-table-column>
        <el-table-column type="name" label="日期" align="center"></el-table-column>
        <el-table-column type="name" label="添加时间" align="center"></el-table-column>

        <el-table-column label="操作" width="180px" align="center">
          <template slot-scope="{ row }">
            <el-popconfirm @confirm="handleDeleteItem(row.id)" title="确认删除吗？">
              <el-button slot="reference" type="primary" plain size="mini">删除</el-button>
            </el-popconfirm>
          </template>
        </el-table-column>
      </el-table>
    </card>

    <configEditorDialog type="departmentConfigure" :visible.sync="configEditorDialog.visible" :details="currentRow" @success="handleEditSuccess"></configEditorDialog>
  </div>
</template>

<script>
import card from "@/components/card";
import tablePage from "@/components/tablePage";
import configEditorDialog from "@/views/system/components/configEditorDialog";
import * as holidayManageAPI from "@/api/holidayManage";
import * as statisticsApi from "@/api/statistics";
import { removeEmptyChildren } from "@/utils/common";

export default {
  name: "holidayManage",
  components: { configEditorDialog, tablePage, card },
  data() {
    return {
      searchForm: {
        evaluateDate: "",
      },
      departmentTree: [],
      configEditorDialog: {
        visible: false,
      },
      currentRow: {},
    };
  },
  created() {
    // this.fetchDepartmentTree();
  },
  methods: {
    requestFunc: holidayManageAPI.list,
    fetchDepartmentTree() {
      statisticsApi.getByCode().then((res) => {
        const result = res.result;
        if (result) {
          removeEmptyChildren([result]);
          this.departmentTree = [result];
        }
      });
    },
    handleEditSuccess() {
      this.$refs.tablePage.playLoadData();
    },
    handleShowRoleEditorDialog(row) {
      this.currentRow = { ...row };
      this.configEditorDialog.visible = true;
    },
  },
};
</script>

<style scoped></style>
